#ifndef __FDCAN_INTERFACE_H__
#define __FDCAN_INTERFACE_H__

#include "stm32h7xx.h"
#include "fdcan.h"

#define CAN_MSG_QUEUE_LENGTH    32

#define USE_FDCAN1  1
#define USE_FDCAN2  1

#pragma anon_unions
#pragma pack(1) 
typedef struct
{
    uint32_t id;
    uint8_t length;
    uint8_t data[64];
}can_msg_s;

typedef struct
{
    can_msg_s can_msg[CAN_MSG_QUEUE_LENGTH];
    uint8_t write_index;
    uint8_t read_index;
    uint8_t send_flag;
}can_msg_queue_s;

typedef struct
{
    can_msg_s can_msg[CAN_MSG_QUEUE_LENGTH];
    uint8_t write_index;
    uint8_t read_index;
}can_rx_queue_s;

#pragma pack ()

void fdcan_filter_init(FDCAN_HandleTypeDef * fdcanHandle);
void fdcan_filter_init1(FDCAN_HandleTypeDef * fdcanHandle);
void fdcan_send(FDCAN_HandleTypeDef * fdcanHandle, uint32_t id, uint8_t *data, uint16_t size);
uint32_t fdcan_recv(FDCAN_HandleTypeDef *hfdcan, FDCAN_RxHeaderTypeDef *RxHeader);

void fdcan_push_queue(FDCAN_HandleTypeDef * fdcanHandle, uint32_t id, uint8_t *data, uint16_t size);
void fdcan_pull_queue(void);

extern can_rx_queue_s can_rx_queue1;
extern can_rx_queue_s can_rx_queue2;

#endif
